package com.hpin.fansea.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpin.fansea.R;
import com.hpin.fansea.bean.GuideList;

import java.util.List;

/**
 * Created by Aaron on 15/9/9.
 */
public class SpGuideListAdapter extends BaseAdapter {

    private Context context;
    private List<GuideList> guideLists;

    public SpGuideListAdapter(Context context, List<GuideList> guideLists) {
        this.context = context;
        this.guideLists = guideLists;
    }

    public void setData(List<GuideList> guideLists) {
        this.guideLists = guideLists;
    }

    @Override
    public int getCount() {
        return guideLists.size();
    }

    @Override
    public Object getItem(int position) {
        return guideLists.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_service_guide,
                    null);
            viewHolder = new ViewHolder();
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.item_service_guide_title);


            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        
        viewHolder.tv_title.setText(guideLists.get(position).guideName);

        return convertView;
    }

    private class ViewHolder {
        public TextView tv_title;
    }

}
